import '../model/result_model.dart';
import '../model/school_grade_subject_model.dart';
import '../utils/request.dart';

///学校年级学科-API
class SchoolGradeSubjectApi {
  SchoolGradeSubjectApi._();

  static final _signleton = SchoolGradeSubjectApi._();

  factory SchoolGradeSubjectApi() => _signleton;

  ///分页查询
  Future<SchoolGradeSubjectQueryRes> query(SchoolGradeSubjectQueryReq req) =>
      request
          .getHandler(
            path: '/school/${req.schoolId}/subject',
            params: req.toMap(),
          )
          .then((res) => SchoolGradeSubjectQueryRes.fromModel(res));

  ///加载
  Future<SchoolGradeSubjectInfoRes> info(final String id) => request
      .getHandler(path: '/school/subject/$id')
      .then((res) => SchoolGradeSubjectInfoRes.fromModel(res));

  ///新增
  Future<BaseModelRes> add(final SchoolGradeSubjectAddReq req) => request
      .postHandler(path: '/school/${req.schoolId}/subject', data: req.toMap());

  ///修改
  Future<BaseModelRes> modify(final SchoolGradeSubjectModifyReq req) =>
      request.putHandler(path: '/school/subject/${req.id}', data: req.toMap());

  ///删除
  Future<BaseModelRes> delete(final String id) =>
      request.deleteHandler(path: '/school/subject/$id');
}

/// 学校年级学科-接口单例
final schoolGradeSubjectApi = SchoolGradeSubjectApi();
